Title: SQL W3S (By-BKK) / 116 Dates
Tags: Obsidian_to_Anki

Q: What is the main challenge when working with dates in SQL?
A: Matching the format of the date you insert with the format expected by the date column

Q: True or False: Adding a time portion to a date makes queries more complicated in SQL
A: True

Q: What is the data type in MySQL used to store only a date with no time?
A: DATE

Q: What format does the MySQL DATE type use?
A: YYYY-MM-DD

Q: In MySQL, which data type stores both date and time values?
A: DATETIME

Q: What is the format for DATETIME or TIMESTAMP in MySQL?
A: YYYY-MM-DD HH:MI:SS

Q: How can you store just the year in MySQL?
A: Use the YEAR data type

Q: True or False: The MySQL YEAR type accepts the format YYYY or YY
A: True

Q: What data type in SQL Server stores only a date?
A: DATE

Q: What is the format for the DATE type in SQL Server?
A: YYYY-MM-DD

Q: Which data types in SQL Server can store both date and time?
A: DATETIME and SMALLDATETIME

Q: What is special about the TIMESTAMP type in SQL Server?
A: It stores a unique number, not a date or time

Q: True or False: You choose the date type for a column when creating a new table
A: True

Q: If your query compares two dates with no time portion, will it work as expected?
A: Yes

Q: If you compare a date with a time portion to a date without a time portion in SQL, what happens?
A: No result will be returned

Q: Reverse card:
YYYY-MM-DD HH:MI:SS
A: Format for DATETIME or TIMESTAMP in MySQL

Q: Reverse card:
DATE, DATETIME, TIMESTAMP, YEAR
A: Date data types in MySQL

Q: Reverse card:
Keep queries simple by avoiding time-components in dates unless necessary
A: Tip for working with dates in SQL

Q: Reverse card:
True
A: You choose the date type for a column when creating a new table in SQL

Q: Reverse card:
SQL Server TIMESTAMP
A: Stores a unique number, not a date/time value